#ifndef __LEX__
#define __LEX__

#include <cstdlib>
#include <fstream>

typedef enum
{
	LEFT_PARENT,	//	left parenthesis
	RIGHT_PARENT,	//	right parenthesis
	LITERAL,		//	literal atom
	NUMBER,			//	number atom
	DOT,			//	dot
	ERROR,
	END,
}TokenType;

struct Token
{
	TokenType type;		//
	std::string str;	//	content of token
	int number;			//	translated to a number if it's number

	Token()
		: type(END), str(""), number(0)
	{}

	Token(TokenType type, std::string str, int number)
		: type(type), str(str), number(number)
	{}

	void set(TokenType t, std::string s, int n)
	{
		type = t;
		str = s;
		number = n;
	}

	bool end()
	{
		return type == END;
	}

	bool error()
	{
		return type == ERROR;
	}
};


class Lex
{
public:
	Lex();
	~Lex(void);

public:
	Token currentToken;		//	current token

public:
	// read next token
	void nextToken();
	// match and consume a token
	bool matchToken(TokenType tokenType);

	// reset the current token
	void reset(void);
};

#endif
